<template>
	<view class="confirmOuterhouse">
		<view class="cartType">
			<view class="cartType_item">
				<view>
					<em style="display: inline-block ;color: #f00;">*</em>
					客户姓名：
					<view style="display: inline-block;vertical-align:middle;">
						<u-input
						v-model="user_name" 
						placeholder="请输入客户姓名" 
						:type="type" 
						:border="true"
						border-color="#707070FF"/>
					</view>
				</view>
			</view>
			<view class="cartType_item">
				<view>
					<em style="display: inline-block ;color: #f00;">*</em>
					客户电话：
					<view style="display: inline-block;vertical-align:middle;">
						<u-input
						v-model="user_phone" 
						placeholder="请输入客户电话" 
						:type="type" 
						:border="true"
						border-color="#707070FF"/>
					</view>
				</view>
			</view>
			<view class="cartType_item">
				<view>
					<em style="display: inline-block ;color: #f00;">*</em>
					详细地址：
					<u-input v-model="user_local" type="textarea" :border="false" :height="96" :auto-height="true" />
				</view>
			</view>
			<view class="cartType_item">
				<view>
					<em style="display: inline-block ;color: #f00;">*</em>
					备注用途：
					<view style="display: inline-block;vertical-align:middle;">
						<u-input
						v-model="comment" 
						placeholder="请输入备注" 
						:type="type" 
						border-color="#707070FF"/>
					</view>
				</view>
			</view>
			<view>
				<view style="padding: 0 32.04rpx 20rpx 32.04rpx">货品名称：</view>
				<scroll-view scroll-y class="content_scroll">
					<yt-card head=" " v-for="(item,index) in selectcarts" :key="index">
						<view class="content">
							<view class="content_img_box">
								<image class="content_img" src="https://vkceyugu.cdn.bspapp.com/VKCEYUGU-baf89db3-4d55-4b1f-a05e-c0a1170f8dce/981a7502-fefb-4ff6-bec6-7513cd717fa7.jpg"></image>
							</view>
							<view class="content_text">
								<view class="content_text_cartName">
									商品名称：<text style="color: #9E2424FF;">{{item.cartName}}</text>
								</view>
								<view class="content_text_type">
									<view class="type_1">
										灶具进风：<text style="color: #9E2424FF;margin-right: 20rpx;">{{item.jf}}</text>
										气源类别：<text style="color: #9E2424FF;">{{item.lb}}</text>
									</view>
									<view class="type_2">
										灶具出风：<text style="color: #9E2424FF;margin-right: 20rpx;">{{item.cf}}</text>
										灶眼数量：<text style="color: #9E2424FF;">{{item.zysl}}</text>
									</view>
								</view>
							</view>
						</view>
					</yt-card>
				</scroll-view>
			</view>
			<view class="subimt_ruku">
				<yt-botton btname="出库申请" @click="subimt_sp"></yt-botton>
			</view>
		</view>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	import ytBotton from '../../comment/yt-botton.vue'
	import ytCard from '../../comment/yt-card.vue'
	export default {
		data() {
			return {
				user_name:'',
				user_phone:'',
				user_local:'',
				selectcarts:[],
				applicant_id:'',
				applicant:'',
				outhouse:'',
				number:1,
				comment:''
			};
		},
		onLoad(option) {
			var { applicant_id,applicant,selectCarts,outerhouse_name } = option
			this.selectcarts = JSON.parse(decodeURIComponent(selectCarts))
			this.applicant_id = decodeURIComponent(applicant_id)
			this.applicant = decodeURIComponent(applicant)
			this.outhouse = decodeURIComponent(outerhouse_name)
			this.number = this.selectcarts.length
			console.log(this.outhouse)
		},
		methods:{
			subimt_sp(){
				if(this.user_name == ""){
					this.$refs.uToast.show({
						title: '必须填写客户姓名！',
						type: 'error',
						position:"top"
					})
				}else if(this.user_phone == ""){
					this.$refs.uToast.show({
						title: '必须填写客户电话！',
						type: 'error',
						position:"top"
					})
				}else if(this.user_local == ""){
					this.$refs.uToast.show({
						title: '必须填写详细地址！',
						type: 'error',
						position:"top"
					})
				}else{
					var Vue = this;
					uni.showModal({
						title:'提交审批',
						content:'您确定提交该条审批吗？',
						success(res) {
							if(res.confirm){
								uniCloud.callFunction({
									name: 'uni-id-cf_mobile',
									data: {
										action:"outerhouse_sp",
										params:{
											applicant_id_outerhouse:Vue.applicant_id,//审批发起人id"
											applicant_outerhouse:Vue.applicant,//"审批发起人用户名"
											outhouse_outerhouse:Vue.outhouse,//"出货仓库"
											transferhouse_outerhouse:"",//"转库目标仓库"
											client_outerhouse:Vue.user_name,//"客户姓名"
											client_phone_outerhouse:Vue.user_phone,//"客户电话"
											client_local_outerhouse:Vue.user_local,//"客户详细地址"
											number_outerhouse:Vue.number,//出货货品数量"
											cart_names_outerhouse:Vue.selectcarts,//"多个货品名称"array
											istransfer_outerhouse:false,//"是否转库审批"
											comment_outerhouse:Vue.comment//备注
										}
									}
								}).then(({result}) => {
									if(result.code){
										this.$refs.uToast.show({
											title: '出错了！请重新登录。',
											type: 'error',
											position:"top"
										})
										uni.reLaunch({
											url:'../login/login'
										})
										uni.hideLoading()
										return;
									}else{
										uni.redirectTo({
											url:"../houseToHouse/houseToHouse?success=true"
										})
										let count = uni.getStorageSync("count")
										uni.setStorageSync("count",count++)
										uni.hideLoading()
									}
									console.log(result)
								}).catch(err => {
									console.log(err)
								})
							}
						}
					})
				}
			}
		},
		components:{
			ytBotton,
			ytCard
		}
	}
</script>

<style lang="scss">
.confirmOuterhouse{
	position: absolute;
	width: 100%;
	min-height: 1480rpx;
	background-color: #EEEEEEFF;
	.cartType{
		.cartType_item{
			padding: 26.7rpx 32.04rpx;
			background-color: #FFFFFF;
			margin:21.36rpx 0;
			font-size: 30rpx;
		}
	}
	.subimt_ruku{
		margin-top: 77.43rpx;
	}
	.content_scroll{
		display: block;
		height: 30vh;
	}
	.content{
		display: inline-flex;
		.content_img_box{
			.content_img{
				border: 2.67rpx solid #7070703D;
				border-radius: 40.05rpx;
				width: 150rpx;
				height: 150rpx;
				margin-right: 20rpx;
			}
		}
		.content_text{
			font-size: 20rpx;
			.content_text_cartName{
				margin-bottom: 25rpx;
			}
			.content_text_type{
				
				.type_1{
					margin-bottom: 25rpx;
				}
				.type_2{
					margin-bottom: 25rpx;
				}
			}
		}
	}
}
</style>
